<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      #box {
        width: 400px;
        height: 400px;
        border: solid;
        position: relative;
      }
      #box .mouse {
        width: 100px;
        height: 100px;
        background-color: bisque;
        border: solid;
        position: absolute;
        font-size: 40px;
      }
    </style>
  </head>
  <body>
    <div id="box">
      <div id="m1" class="mouse">m1</div>
      <div id="m2" class="mouse">m2</div>
    </div>

    <script>
      const m1 = document.getElementById("m1");
      window.onkeydown = (e) => {
        if (e.key === "ArrowUp") {
          m1.style.top = m1.offsetTop - 10 + "px";
        }
        if (e.key === "ArrowDown") {
          m1.style.top = m1.offsetTop + 10 + "px";
        }
        if (e.key === "ArrowLeft") {
          m1.style.left = m1.offsetLeft - 10 + "px";
        }
        if (e.key === "ArrowRight") {
          m1.style.left = m1.offsetLeft + 10 + "px";
        }
      };
    </script>
  </body>
</html>
